package com.yoso.service;


import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

@Service
@Slf4j
public class WebService {

    private AtomicInteger count = new AtomicInteger(0);

    public void sleep(Integer seconds) {
        if (ObjectUtil.isNotNull(seconds)) {
            ThreadUtil.sleep(seconds, TimeUnit.SECONDS);
        }
        int andIncrement = count.getAndIncrement();

        log.info(String.valueOf(andIncrement));
    }


    public void clear() {
        count.set(0);
    }
}
